// redux核心库，createStore创建store，applyMiddleware应用异步action中间件
import { createStore, applyMiddleware } from 'redux'
// 异步action中间件thunk
import thunk from 'redux-thunk'
// redux开发工具
import { composeWithDevTools } from 'redux-devtools-extension'
// redux-persist：刷新页面时，从sessionStorge中恢复store中的数据
import { persistStore, persistReducer } from 'redux-persist';
//  存储机制，可换成其他机制，当前使用sessionStorage机制
import storageSession from 'redux-persist/lib/storage/session'

// reducers
import reducers from './reducers'

// 数据对象
const storageConfig = {
    key: 'root', // 必须有的
    storage: storageSession, // 缓存机制
    blacklist: [], // reducer 里不持久化的数据,除此外均为持久化数据
};

const myPersistReducer = persistReducer(storageConfig, reducers);
const store = createStore(myPersistReducer, composeWithDevTools(applyMiddleware(thunk)))
export default store

export const persistor = persistStore(store);